< previous page page_24 next page >

Page 24
Point Method
The Point method returns the color of the pixel at the specified coordinates. Its syntax is:
Point (x, y)
x, y The coordinates of the point.
The PSet and Point methods complement each other: one gets the color of a pixel, and the other sets the color of a pixel. Like the PSet method, the Point method is easiest to use when the drawing object's ScaleMode is vbPixels.
You could use the PSet and Point methods to make the right half of a picture box named picMirror display a reflected image of its left half using the following code:
e10a6a0a59f035e870d90cca05b85fce.gif
Dim X As Single
Dim Y As Single
Dim wid As Single
Dim hgt As Single

    ' Work in pixels.
    picMirror.ScaleMode = vbPixels
      
    ' Get the image's dimensions.
    wid = picMirror.ScaleWidth
    hgt = picMirror.ScaleHeight

    ' Mirror.
    For X = 0 To wid / 2
        For Y = 0 To hgt
            picMirror.PSet (wid - X, Y), picMirror.Point(X, Y) 
        Next Y 
    Next X
Note that you can achieve the same effect more efficiently using the PaintPicture method. If you give PaintPicture a negative width for the source image, the routine stretches the image by a factor of 1 to make it fit in the destination image. This makes a mirror image of the source appear in the destination. Because you are using a negative width, you must also specify the upper-right corner rather than the upper-left corner as the start of the source image. The following code does the same thing as the previous code using PaintPicture.
e10a6a0a59f035e870d90cca05b85fce.gif
Dim wid As Single
Dim hgt As Single

    ' Get the area's dimensions. 
    wid = PaintPict.ScaleWidth / 2 
    hgt = PaintPict.ScaleHeight 

    ' Mirror the area.
    picMirror.PaintPicture picMirror, _

 
< previous page page_24 next page >